#-*- coding:utf-8 -*-
from selenium import webdriver
import unittest

class login2(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.maximize_window()
        self.driver.get(
            "https://passport.jd.com/new/login.aspx?ReturnUrl=https%3A%2F%2Fwww.jd.com%2F%3Fcu%3Dtrue%26utm_source%3Dbaidu-pinzhuan%26utm_medium%3Dcpc%26utm_campaign%3Dt_288551095_baidupinzhuan%26utm_term%3D0f3d30c8dba7459bb52f2eb5eba8ac7d_0_f96bb5f6af3a4b659b87e65dd4282e76")
        self.driver.implicitly_wait(10)

        self.login_tab_r = self.driver.find_element_by_class_name("login-tab-r")
        self.loginname = self.driver.find_element_by_id("loginname")
        self.nloginpwd = self.driver.find_element_by_id("nloginpwd")
        self.loginsubmit = self.driver.find_element_by_id("loginsubmit")

        self.login_box = self.driver.find_element_by_class_name("login-box")
        self.qrcode_ogin = self.driver.find_element_by_class_name("qrcode-login")
        pass
    def tearDown(self):
        self.driver.quit()
        pass
    def test_us_em_pw_em(self):
        u"""用户名为空,密码为空,应该提示请输入用户名"""
        self.login_tab_r.click()
        if self.login_box.is_displayed() ==True:
            self.loginname.clear()
            self.nloginpwd.clear()
            self.loginsubmit.click()

            self.msg = self.driver.find_element_by_class_name("msg-error")
            self.text=self.msg.text

            self.assertAlmostEqual(self.text,u"请输入账户名和密码")
        else:
            u"""用户名div不可见,网络原因造成"""
            self.assertEqual(self.login_box.is_displayed(), "True")


        pass
    def test_us_em_ps_eme(self):
        u"""空！！！"""
        pass